package com.gary.demo.service.impl;

import com.gary.demo.domain.User;
import com.gary.demo.mapper.UserMapper;
import com.gary.demo.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Service
public class UserServiceImpl implements UserService {

    //    @Autowired
    private UserMapper userMapper;

    @Autowired
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User getOne() {
        User user = new User();
        user.setId(1L);
        return this.userMapper.selectOne(user);
    }

    @Override
    public List<User> getUsers() {
        //        return null;
        PageHelper.startPage(5,10);
       return this.userMapper.selectAll();
//        return this.userMapper.selectByRowBounds(new User(),new RowBounds(5,10));
//        return PageHelper.startPage(5, 10).doSelectPageInfo(() -> userMapper.selectAll());
        //        return this.userMapper.(new User(),new RowBounds(5,10));
    }
}
